#define _CRT_SECURE_NO_WARNINGS	

#include<stdio.h>

int judge(int x)
{
    while (x)
    {
        if (x % 10 >= 5)
            return 0;
        x /= 10;
    }
    return 1;
}

int main()
{
    int n;
    scanf("%d", &n);
    int cnt = 0;
    while (n > 0)
    {
        cnt += judge(n);
        scanf("%d", &n);
    }
    printf("%d", cnt);
    return 0;
}